<template>
    <div class="fromBox">
        <el-form ref="ruleForm" :model="ruleForm" :rules="rules">
            <el-form-item prop="title">
                <el-input v-model="ruleForm.title" size="small" placeholder="项目名称"></el-input>
            </el-form-item>
            <el-form-item prop="description">
                <el-input v-model="ruleForm.description" rows="27" placeholder="项目简介: 支持 markDown 语法" resize="none" type="textarea" size="small">
                </el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    props: ['projectData', 'submitEdit'],
    data() {
        return {
            ruleForm: {
                projectId: '',
                title: '',
                description: '',
            },
            rules: {
                title: { required: true, message: '请输入项目名', trigger: 'change' },
            }
        }
    },
    mounted() {
        this.ruleForm.projectId = this.projectData.projectId;
        this.ruleForm.title = this.projectData.title;
        this.ruleForm.description = this.projectData.description;
    },
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.submitEdit(this.ruleForm);
                } else {
                    return false;
                }
            });
        }
    },
}
</script>

<style scoped>
    .fromBox { padding: 0 40px;}
</style>